#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        for (int i = m + n - 1; i >= n; i--) nums1[i] = nums1[i - n];
        int index_x = n, index_y = 0, index = 0;
        for (int i = 0; i < n + m; i++)
        {
            if (index_x >= m + n) nums1[i] = nums2[index_y++];
            else if (index_y >= n) nums1[i] = nums1[index_x++];
            else nums1[i] = nums1[index_x] > nums2[index_y] ? nums2[index_y++] : nums1[index_x++];
        }
    }
};